import {AfterViewChecked, AfterViewInit, Component, OnInit, ViewChild} from '@angular/core';
import {ChildComponent} from '../child/child.component';
import {ViewChildComponent} from '../view-child/view-child.component';

@Component({
  selector: 'app-view',
  templateUrl: './view.component.html',
  styleUrls: ['./view.component.css']
}) /*在模板已经初始化完成后被调用*/
export class ViewComponent implements OnInit, AfterViewInit, AfterViewChecked {

  /*通过child1 找到ViewChildComponent */
  @ViewChild('child1')
  child1: ViewChildComponent;

  constructor() {
  }

  ngOnInit(): void {
    this.child1.greeting('Tom');
  }

  ngAfterViewInit(): void {
    console.log('父组件的视图初始化完毕');
  }

  ngAfterViewChecked(): void {
    console.log('父组件的视图变更检查化完毕');
  }

}
